﻿package payments;
import java.awt.*;
import java.awt.event.*;

public class NewChFrame extends Dialog implements ActionListener {

		private static final long serialVersionUID = 1L;
		
		private Button yes = new Button("ok");
				
		private boolean result;

	  public NewChFrame(Frame parent, String message)
	  {
	    super(parent, true);
	  	    
	    Panel p = new Panel();
	    GridBagLayout gbl = new GridBagLayout();
	    p.setLayout(gbl);
	    //p.setLayout(new GridBagLayout());
	    	   
	    TextArea printP = new TextArea();
	    
	    Font times10pt = new Font(null, 10,10);	
	    
	    printP.setFont(times10pt);
	    printP.setEditable(false);
	    	
	    GridBagConstraints c = new GridBagConstraints();
        
        c.anchor = GridBagConstraints.NORTHWEST; 
        c.fill   = GridBagConstraints.BOTH;
                 
        c.ipadx = 1;
        c.ipady = 1;
        c.insets = new Insets(0, 0, 0, 1);
       	 
        c.weighty = 1.0;
        c.weightx = 1.0;
        
        c.gridwidth  = GridBagConstraints.REMAINDER;	//занять остаток строки
        c.gridheight = 1;							   	//Количество ячеек в колонке
        c.gridx = 0;									//Номер ячейки в строке
        c.gridy = 0;									//Номер ячейки в столбце
	    
	    
        gbl.setConstraints(printP, c);   
   		p.add(printP);
	    //p.add(printP,new GridBagConstraints(2, 0, 2, 1, 1, 1,
	    //        GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
	    	    
	    printP.setText(message);
	    
	    yes.addActionListener(this);
	    
	    c.fill   = GridBagConstraints.HORIZONTAL;
	    c.gridheight  =  GridBagConstraints.REMAINDER ;
	    c.gridy = 1;	
	    
	    gbl.setConstraints(yes, c);   
   		p.add(yes);
	    
	    
	    //p.add(yes,new GridBagConstraints(2, 1, 2, 1, 1, 0,
	    //        GridBagConstraints.SOUTH, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
	   	    
	    this.add(p);
	    //this.setSize(300,300);
	    //this.setLocation(50, 50);
	    this.pack();
	    //this.setVisible(true);
	  }  
	  
	  public void actionPerformed(ActionEvent evt) {
		
		  if (evt.getSource() == yes) result = true;
		    else result = false;
		  
		  this.setVisible(false);
		  this.dispose();
	  }
	  
	  public boolean getResult() {
		    return result;
		  }
	}
	
